package dynamoscaffold

class DynamoJSController {

    def index = {

      render("function showHideDataRow(elementName) {\n" +
            "\n" +
            "    var elementId = '#' + elementName;\n" +
            "    if (\$(elementId).is(':visible')) {\n" +
            "        \$(elementId).fadeOut()\n" +
            "    }\n" +
            "    else {\n" +
            "        \$(elementId).fadeIn()\n" +
            "    }\n" +
            "\n" +
            "}\n" +
            "\n" +
            "function removeElement(elementName)   {\n" +
            "\n" +
            "     var elementId = '#' + elementName;\n" +
            "\n" +
            "     \$(elementId).fadeOut('slow', function() {\n" +
            "         \$(elementId).remove();\n" +
            "     });\n" +
            "}\n" +
            "\n" +
            "function clear_form_elements(ele) {\n" +
            "\n" +
            "    \$(ele).find(':input').each(function() {\n" +
            "        switch(this.type) {\n" +
            "            case 'password':\n" +
            "            case 'select-multiple':\n" +
            "            case 'select-one':\n" +
            "            case 'text':\n" +
            "            case 'textarea':\n" +
            "                \$(this).val('');\n" +
            "                break;\n" +
            "            case 'checkbox':\n" +
            "            case 'radio':\n" +
            "                this.checked = false;\n" +
            "        }\n" +
            "    });\n" +
            "\n" +
            "}")

    }
}
